package com.sunny.wordstudy;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.sunny.wordstudy.lib.Stat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Word extends Activity
{
  List<Map<String, Object>> cmdDatas;
  AdapterView.OnItemClickListener cmdListHandler = new 1(this);
  ListView cmdlist;
  Stat iStat = Stat.getInstance();
  ProgressDialog myProgressDialog = null;
  String sImei;

  private OutputStream OutputStream(String paramString)
  {
    return null;
  }

  private void copyDefaultStudyFile()
  {
    String str = null;
    PackageManager localPackageManager = getPackageManager();
    try
    {
      str = localPackageManager.getApplicationInfo("com.sunny.wordstudy", 0).dataDir;
      label18: new StringBuilder(String.valueOf(str)).append("/res/raw/usr_sunny.mp3").toString();
      InputStream localInputStream = getResources().openRawResource(2131034112);
      byte[] arrayOfByte = new byte[1024];
      try
      {
        new File("/sdcard/wordstudy").mkdirs();
        FileOutputStream localFileOutputStream = new FileOutputStream("/sdcard/wordstudy/usr_sunny.edb");
        int i = localInputStream.read(arrayOfByte);
        if (i == -1)
        {
          localInputStream.close();
          localFileOutputStream.close();
          return;
        }
        localFileOutputStream.write(arrayOfByte, 0, i);
        int j = localInputStream.read(arrayOfByte);
        i = j;
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
      }
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      break label18:
    }
  }

  private List<Map<String, Object>> getCmds()
  {
    ArrayList localArrayList = new ArrayList();
    HashMap localHashMap1 = new HashMap();
    localHashMap1.put("id", "study");
    localHashMap1.put("title", getResources().getString(2131165190));
    localHashMap1.put("desc", getResources().getString(2131165191));
    localArrayList.add(localHashMap1);
    HashMap localHashMap2 = new HashMap();
    localHashMap2.put("id", "test");
    localHashMap2.put("title", getResources().getString(2131165192));
    localHashMap2.put("desc", getResources().getString(2131165193));
    localArrayList.add(localHashMap2);
    HashMap localHashMap3 = new HashMap();
    localHashMap3.put("id", "choosedb");
    localHashMap3.put("title", getResources().getString(2131165200));
    localHashMap3.put("desc", getResources().getString(2131165201));
    localArrayList.add(localHashMap3);
    HashMap localHashMap4 = new HashMap();
    localHashMap4.put("id", "setting");
    localHashMap4.put("title", getResources().getString(2131165194));
    localHashMap4.put("desc", getResources().getString(2131165195));
    localArrayList.add(localHashMap4);
    HashMap localHashMap5 = new HashMap();
    localHashMap5.put("id", "about");
    localHashMap5.put("title", getResources().getString(2131165196));
    localHashMap5.put("desc", getResources().getString(2131165197));
    localArrayList.add(localHashMap5);
    return localArrayList;
  }

  private void loadStudyDB(String paramString)
  {
    if (paramString.equals(""));
    for (String str = "/sdcard/wordstudy/usr_sunny.edb"; ; str = "/sdcard/wordstudy/" + paramString)
    {
      File localFile = new File(str);
      if ((localFile.exists()) && (localFile.length() < 4096L))
        localFile.delete();
      if (!(localFile.exists()))
      {
        copyDefaultStudyFile();
        str = "/sdcard/wordstudy/usr_sunny.edb";
      }
      this.iStat.setStudy(str);
      return;
    }
  }

  private void setDBStatus()
  {
    TextView localTextView1 = (TextView)findViewById(2131230720);
    SharedPreferences localSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    this.iStat.setRegSN(localSharedPreferences.getString("regsn", ""));
    StringBuilder localStringBuilder1 = new StringBuilder(String.valueOf(this.iStat.getStudyBookName())).append(" ");
    Resources localResources1 = getResources();
    Object[] arrayOfObject1 = new Object[2];
    arrayOfObject1[0] = Long.valueOf(this.iStat.getTotalIntroducedWords());
    arrayOfObject1[1] = Long.valueOf(this.iStat.getBookWords());
    StringBuilder localStringBuilder2 = new StringBuilder(String.valueOf(localResources1.getString(2131165189, arrayOfObject1))).append(" ");
    Resources localResources2 = getResources();
    Object[] arrayOfObject2 = new Object[2];
    arrayOfObject2[0] = Long.valueOf(this.iStat.getTotalLearnedTime() / 60L);
    arrayOfObject2[1] = Long.valueOf(this.iStat.getTotalLearnedTime() % 60L);
    localTextView1.setText(localResources2.getString(2131165188, arrayOfObject2));
    TextView localTextView2 = (TextView)findViewById(2131230722);
    String str;
    if (this.iStat.getReged() == 0)
    {
      str = " IMEI:" + this.sImei;
      localTextView2.setTextColor(-65536);
    }
    while (true)
    {
      localTextView2.setText(str);
      return;
      str = " " + getResources().getString(2131165226);
      localTextView2.setTextColor(-16776961);
    }
  }

  void alterDBVerFail()
  {
    switch (this.iStat.checkStudyDBVer())
    {
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    }
    for (String str = getResources().getString(2131165229); ; str = getResources().getString(2131165230))
      while (true)
      {
        new AlertDialog.Builder(this).setIcon(getResources().getDrawable(2130837504)).setTitle(getResources().getString(2131165212)).setMessage(str).setPositiveButton(getResources().getString(2131165202), new 8(this)).show();
        return;
        str = getResources().getString(2131165228);
        continue;
        str = getResources().getString(2131165229);
      }
  }

  void alterExpired()
  {
    String str = getResources().getString(2131165227);
    new AlertDialog.Builder(this).setIcon(getResources().getDrawable(2130837504)).setTitle(getResources().getString(2131165212)).setMessage(str).setPositiveButton(getResources().getString(2131165202), new 9(this)).show();
  }

  void alterNeedReg()
  {
    String str = getResources().getString(2131165227);
    new AlertDialog.Builder(this).setIcon(getResources().getDrawable(2130837504)).setTitle(getResources().getString(2131165212)).setMessage(str).setPositiveButton(getResources().getString(2131165202), new 10(this)).show();
  }

  void alterRegRun()
  {
    String str = getResources().getString(2131165227);
    new AlertDialog.Builder(this).setIcon(getResources().getDrawable(2130837504)).setTitle(getResources().getString(2131165212)).setMessage(str).setPositiveButton(getResources().getString(2131165202), new 11(this)).show();
  }

  public void chooseChooseDBView()
  {
    startActivityForResult(new Intent(this, ChooseDBView.class), 0);
  }

  public void chooseDictView()
  {
    startActivityForResult(new Intent(this, ChooseDBView.class), 0);
  }

  public void chooseSettingView()
  {
    startActivityForResult(new Intent(this, SettingView.class), 0);
  }

  public void chooseStudyView()
  {
    SharedPreferences localSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor localEditor = localSharedPreferences.edit();
    localEditor.putBoolean("lastlearnmode", true);
    localEditor.commit();
    int i = Integer.parseInt(localSharedPreferences.getString("studymode", "0"));
    if (this.iStat.checkStudyDBVer() != 0)
      alterDBVerFail();
    while (true)
    {
      return;
      if (this.iStat.getTotalLearnTime1(true) > 0L)
        alterExpired();
      if (this.iStat.check0(4, 4 - i))
        alterNeedReg();
      if ((this.iStat.getReged() == 0) && (Math.round(1000.0D * Math.random()) % 4L == 0L))
        alterRegRun();
      startActivityForResult(new Intent(this, StudyView.class), 0);
    }
  }

  public void chooseTestView()
  {
    SharedPreferences localSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    SharedPreferences.Editor localEditor = localSharedPreferences.edit();
    localEditor.putBoolean("lastlearnmode", false);
    localEditor.commit();
    int i = 0xF & Integer.parseInt(localSharedPreferences.getString("testmode", "17"));
    if (this.iStat.checkStudyDBVer() != 0)
      alterDBVerFail();
    while (true)
    {
      return;
      if (this.iStat.getTotalLearnTime1(true) > 0L)
        alterExpired();
      if (this.iStat.check1(4, 4 - i))
        alterNeedReg();
      if ((this.iStat.getReged() == 0) && (Math.round(1000.0D * Math.random()) % 4L == 0L))
        alterRegRun();
      startActivityForResult(new Intent(this, StudyView.class), 0);
    }
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    setDBStatus();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903041);
    TelephonyManager localTelephonyManager = (TelephonyManager)getSystemService("phone");
    this.sImei = localTelephonyManager.getDeviceId();
    this.iStat.setIMEI(localTelephonyManager);
    this.cmdlist = ((ListView)findViewById(2131230723));
    String[] arrayOfString = new String[2];
    arrayOfString[0] = "title";
    arrayOfString[1] = "desc";
    int[] arrayOfInt = new int[2];
    arrayOfInt[0] = 16908308;
    arrayOfInt[1] = 16908309;
    this.cmdDatas = getCmds();
    SimpleAdapter localSimpleAdapter = new SimpleAdapter(this, this.cmdDatas, 17367044, arrayOfString, arrayOfInt);
    this.cmdlist.setAdapter(localSimpleAdapter);
    this.cmdlist.setOnItemClickListener(this.cmdListHandler);
    if (new File("/sdcard/wordstudy/dict.edb").exists())
      this.iStat.setDict("/sdcard/wordstudy/dict.edb");
    this.myProgressDialog = ProgressDialog.show(this, getResources().getString(2131165211), getResources().getString(2131165214), true);
    new 2(this).start();
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    super.onCreateOptionsMenu(paramMenu);
    paramMenu.add(0, 0, 0, "重新学习");
    paramMenu.add(0, 1, 1, "开始学习");
    paramMenu.add(0, 2, 2, "退出软件");
    return true;
  }

  protected void onDestroy()
  {
    Stat.deinit();
    super.onDestroy();
    System.exit(0);
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 0:
    case 1:
    case 2:
    }
    while (true)
    {
      return true;
      new AlertDialog.Builder(this).setTitle(getResources().getString(2131165224)).setMessage(getResources().getString(2131165225)).setPositiveButton(getResources().getString(2131165202), new 3(this)).setNegativeButton(getResources().getString(2131165203), new 4(this)).show();
      continue;
      chooseStudyView();
      continue;
      new AlertDialog.Builder(this).setTitle(getResources().getString(2131165208)).setMessage(getResources().getString(2131165209)).setPositiveButton(getResources().getString(2131165202), new 5(this)).setNegativeButton(getResources().getString(2131165203), new 6(this)).show();
    }
  }

  public void showAbout()
  {
    new AlertDialog.Builder(this).setIcon(getResources().getDrawable(2130837504)).setTitle(getResources().getString(2131165210)).setMessage("作者：Sunny Yu\nGTalk/Email:\nSunnyYu2000@gmail.com\nQQ:21059366\n网站:www.exuexi.com").setPositiveButton(getResources().getString(2131165202), new 7(this)).show();
  }
}

/* Location:           E:\Desktop\Android\yanguangbeidanci\classes_dex2jar.jar
 * Qualified Name:     com.sunny.wordstudy.Word
 * JD-Core Version:    0.5.3
 */